<article class="col-lg-12">
	<div class="card forms">
		<div class="card-header">
			<h3>申请详情</h3>
		</div>
		<div class="card-body">
			<form action="{url:/seller/exchange_update}" method="post" class="form-horizontal">
				<input type="hidden" name="id" value="{$id}" />
				<input type="hidden" name="order_id" value="{$order_id}" />

				<div class="form-group row">
					<label class="col-sm-2">订单号</label>
					<div class="col-sm-10">{$order_no}</div>
				</div>

				<div class="form-group row">
					<label class="col-sm-2">商品信息</label>
					<div class="col-sm-10">
						{set:$is_send = false}
						{foreach:items=Api::run('getOrderGoodsRowById',array('id'=>$order_goods_id))}
						{set:$refundsNum=order_class::refundsDocNums(['order_goods_id' => $order_goods_id,'order_goods_nums' => $order_goods_nums],$item['id'])}
						{if:$item['is_send']!=0}{set:$is_send = true}{/if}
						{set:$goods = JSON::decode($item['goods_array'])}
						<p>
							{$goods['name']} X {$refundsNum}
							<span class="text-red">【商品金额：￥{echo:$refundsNum * $item['real_price']}】</span>
						</p>
						{/foreach}
					</div>
				</div>

				<div class="form-group row">
					<label class="col-sm-2">用户名</label>
					<div class="col-sm-10">
						{set:$user = Api::run('getMemberInfo',$user_id)}
						{$user['username']}
					</div>
				</div>

				<div class="form-group row">
					<label class="col-sm-2">申请时间</label>
					<div class="col-sm-10">{$time}</div>
				</div>

				<div class="form-group row">
					<label class="col-sm-2">申请原因</label>
					<div class="col-sm-10">{$content}</div>
				</div>

				{if:$img_list}
				<div class="form-group row">
					<label class="col-sm-2">图片信息</label>
					<div class="col-sm-10">
						{foreach:items=JSON::decode($img_list) item=$itemImg}
						<a href="{url:$itemImg}" target="_blank">
						    <img class="img-thumbnail" style="width:120px;height:120px;" src="{url:$itemImg}" /></a>
						{/foreach}
					</div>
				</div>
				{/if}

				<div class="form-group row">
					<label class="col-sm-2 col-form-label">处理操作</label>
					<div class="col-sm-10">
					    <div class="form-check form-check-inline">
						    <label class="form-check-label"><input type='radio' name='status' value='2' checked="checked" class="radio-template form-check-input" />同意</label>
						</div>

						<div class="form-check form-check-inline">
						    <label class="form-check-label"><input type='radio' name='status' value='1' class="radio-template form-check-input" />拒绝</label>
                        </div>

						{if:$is_send == true && !$user_send_time}
						<div class="form-check form-check-inline">
						    <label class="form-check-label"><input type='radio' name='status' value='3' checked="checked" class="radio-template form-check-input" />买家填写返还物流信息</label>
						</div>
						{/if}
					</div>
				</div>

				<div class="form-group row" id="sellerSendBox">
					<label class="col-sm-2 col-form-label">填写重发物流</label>
					<div class="col-sm-10">
					    <div class="row">
					        <div class="col">
        					    <select name="seller_freight_id" pattern="required" class="form-control">
        							<option value="">请选择物流公司</option>
        							{foreach:items=Api::run('getFreightCompany')}
        							<option value="{$item['id']}">{$item['freight_name']}</option>
        							{/foreach}
        						</select>
    					    </div>

                            <div class="col">
    						    <input name="seller_delivery_code" type="text" pattern="required" class="form-control" placeholder="填写快递单号">
                            </div>
					    </div>
					</div>
				</div>

				{if:$user_send_time}
				<div class="form-group row">
					<label class="col-sm-2">买家返还物流</label>
					<div class="col-sm-10">
						{$user_send_time}
						<p>
							{foreach:items=Api::run('getFreightCompanyById',array('freight_id'=>$user_freight_id)) item=$tempFreight}
							{$tempFreight['freight_name']}
							{/foreach}

							【快递单号：{$user_delivery_code}】
							<button class="btn btn-default btn-sm" type="button" onclick="freightLine({$user_freight_id},'{$user_delivery_code}')">物流跟踪</button>
						</p>
					</div>
				</div>
				{/if}

				<div class="form-group row">
					<label class="col-sm-2 col-form-label">处理意见</label>
					<div class="col-sm-10">
						<textarea name="dispose_idea" style="height:80px;" class="form-control">{$dispose_idea}</textarea>
					</div>
				</div>

				<div class="form-group row">
					<div class="col-sm-4 offset-sm-2">
						<input type="submit" class="btn btn-primary" value="确 定" />
						<input type="reset" class="btn btn-secondary" value="重 置" />
					</div>
				</div>
			</form>
		</div>
	</div>
</article>

<script type="text/javascript">
//快递跟踪
function freightLine(doc_id,code)
{
	var urlVal = "{url:/block/freight/id/@id@/code/@code@}";
	urlVal = urlVal.replace("@id@",doc_id).replace("@code@",code);
	art.dialog.open(urlVal,{title:'轨迹查询',width:'600px',height:'500px'});
}

//根据操作选项预显示内容
function changeShow()
{
    var statusVal = $('[name="status"]:checked').val();
    if(statusVal == 2)
    {
        $('#sellerSendBox').show();
    }
    else
    {
        $('#sellerSendBox').hide();
    }
}

//加载完毕运行
changeShow();
$('[name="status"]').on("click",changeShow);
</script>